package com.hyt.it.ogt.kq.main.controller.admission;


import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.exception.annotation.ThrowsAdvice;
import com.hyt.it.ogt.kq.common.gov.config.swagger.ApiVersionConstant;
import com.hyt.it.ogt.kq.common.gov.constant.ResponseCode;
import com.hyt.it.ogt.kq.main.controller.base.BaseController;
import com.hyt.it.ogt.kq.service.admission.IExamineeInfoService;
import com.hyt.it.ogt.kq.service.admission.IExamineeTimesService;
import com.hyt.log.annotation.Log;
import com.hyt.swagger.ApiVersion;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 准考证考生批次 前端控制器
 * </p>
 *
 * @author yanghuankun@talkweb.com.cn
 * @since 2023-1-13
 */
@RestController
@Api(tags = "236.准考证考生批次接口", value = "准考证考生批次接口")
@ApiSort(value = 236)
@RequestMapping("/kw/gov/admission/ticket/times")
@Slf4j
public class ExamineeTimesController extends BaseController {

    @Resource
    IExamineeInfoService examineeInfoService;
    @Resource
    IExamineeTimesService examineeTimesService;

    @ApiOperation(
            value = "36.1 生成准考证",
            notes = "20000:成功;",
            response = Boolean.class
    )
    @ApiOperationSort(value = 1)
    @ApiVersion(group = ApiVersionConstant.V2_4_6)
    @Log(module = "准考证考生批次管理", business = "生成准考证")
    @ThrowsAdvice(code = 43360101, print = "生成考生准考证失败")
    @GetMapping("/generateAdmissionTicket")
    public ApiResponse<Boolean> generateAdmissionTicket(@ApiParam(value = "考生批次ID") @RequestParam String examineeTimeId) {
        return ApiResponse.<Boolean>builder()
                .code(ResponseCode.SUCCESS.getCode())
                .data(examineeInfoService.generateExamineeTimeAdmissionTicket(examineeTimeId))
                .build();
    }

    @ApiOperation(
            value = "36.2 取消生成准考证",
            notes = "30000:成功;",
            response = Boolean.class
    )
    @ApiOperationSort(value = 2)
    @ApiVersion(group = ApiVersionConstant.V2_4_6)
    @Log(module = "准考证考生批次管理", business = "取消生成准考证")
    @ThrowsAdvice(code = 43360201, print = "取消生成准考证失败")
    @GetMapping("/cancelGenerate")
    public ApiResponse<Boolean> cancelGenerate(@ApiParam(value = "考生批次ID") @RequestParam String examineeTimeId) {
        return ApiResponse.<Boolean>builder()
                .code(ResponseCode.SUCCESS.getCode())
                .data(examineeInfoService.cancelExamineeTimeGenerate(examineeTimeId))
                .build();
    }

    @ApiOperation(
            value = "36.3 预览准考证",
            notes = "20000:成功;",
            response = Boolean.class
    )
    @ApiOperationSort(value = 3)
    @ApiVersion(group = ApiVersionConstant.V2_4_6)
    @Log(module = "准考证考生批次管理", business = "预览准考证")
    @ThrowsAdvice(code = 43360301, print = "预览准考证失败")
    @GetMapping("/preview")
    public ApiResponse<String> preview(@ApiParam(value = "考生批次ID") @RequestParam String examineeTimeId) {
        return ApiResponse.<String>builder()
                .code(ResponseCode.SUCCESS.getCode())
                .data(examineeTimesService.preview(examineeTimeId))
                .build();
    }
}
